package com.fy56.platform.goodsTracking.web;

import com.fy56.platform.goodsTracking.commons.unit.SystemConstants;
import com.fy56.platform.goodsTracking.model.GoodsPublic;
import com.fy56.platform.goodsTracking.model.GoodstrackedRecordTopPublicF6;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author li
 * @date 2018-03-15 12:34
 */
@Component
public class TraceUtil {

    @Autowired
    private JrptExecutor jrptExecutor;

    private static TraceUtil traceUtil;

    @PostConstruct
    public void init() {
        traceUtil = this;
        traceUtil.jrptExecutor = this.jrptExecutor;
    }


    private static final Logger logger = LoggerFactory.getLogger(TraceUtil.class);

    public static void doPost(GoodsPublic good) {
        try {
            traceUtil.jrptExecutor.uploadSubTracking(SystemConstants.GOODS_URL,good);
        }catch (Exception e){
            logger.error("TraceUtil error",e);

        }
    }
    public static void doPostTop(GoodstrackedRecordTopPublicF6 good) {
        try {
            traceUtil.jrptExecutor.uploadGoodsTrace(SystemConstants.GOODS_URL,"",good);
        }catch (Exception e){
            logger.error("TraceUtil error",e);

        }
    }


}
